#include<iostream>

#include"sorted_array.h"

using namespace std;

int main()
{
  const int SIZE = 10;
  float array[SIZE];
  int size_used = 0;
  float user_values;
  
  cout << "Enter next value to insert: ";
  
  while(cin >> user_values){
    
    array_insert(array, size_used, user_values);
    
    array_print(cout, array, size_used);
    
    if(size_used == SIZE){
      cout << "Array full." << endl;
      break;
    }
    cin.clear();
    cout << "Enter next value to insert: ";
  }

  cout << "\nArray after all insertions: " << endl;
  array_print(cout, array, size_used);

  cin.clear();
  
  float copy[SIZE];
  int copy_size_used = 0;
  array_copy(copy, array, copy_size_used, size_used);
  
  cout << "Enter next value to remove: ";
  
  while(cin >> user_values){
    
    if(array_find(array, size_used, user_values) < 0)
      {
	cout << "No such value." << endl;
	array_print(cout, array, size_used);
	cin.clear();
	cout << "Enter next value to remove: ";
	continue;
      }
    else
      {
	array_remove(array, size_used, array_find(array, size_used, user_values));
	array_print(cout, array, size_used);
	
	if(size_used == 0){
	  break;
	}
      }
    
    cin.clear();
    cout << "Enter next value to insert: ";
  }  

  cin.clear();

  if(array_find(array, size_used, user_values) == 0)
    cout << "\nArray empty." << endl;
 
  cout << "\nArray after all removals: " << endl;
  array_print(cout, array, size_used);
  
  cout << "Copy before all removals:" << endl;
  array_print(cout, copy, copy_size_used);
  cout << endl;
}
